var HarrisAssistant = Class.create(AbstractModule, {


setupWidgets: function() {

		//About
		this.controller.setupWidget(Mojo.Menu.appMenu, {
			omitDefaultItems: true
		}, {
			visible: true,
			items: [
      		Mojo.Menu.editItem,
			{ label: "Disclaimer", command: "do-disclaimer" },					
				{ label: "License", command: "do-license" },
				{ label: "Help", command: "do-help" }
			]
		});

this.help = true;

  this.toggleModel = {
			dialysisCHK: false
		};

	this.toggleunit =
	{
		modelProperty: 'togglestate',
		trueLabel: 'SI',
	falseLabel: 'US'
	};
	this.togglemodel = {
		togglestate: true
	};
	
	
		this.controller.setupWidget("sex", {
			label: "<span class=\"si\">Sex</span>",
			choices: [
				{ label: "Male", value: 1},
				{ label: "Female", value: 0}
			]
		}, this.sexModel = {
			value: 1
		});
	
		this.controller.setupWidget("activity", {
			label: "<span class=\"si\">Activity<sup>*</sup></span>",
			choices: [
				{ label: "Little to no", value: 1.2},
				{ label: "Light exercise", value: 1.375},
				{ label: "Moderate", value: 1.55},
				{ label: "Heavy", value: 1.725},
				{ label: "Very heavy", value: 1.9}
			]
		}, this.activityModel = {
			value: 1.2
		});
	
	
	
	this.controller.setupWidget("unitField", this.toggleunit, this.togglemodel);
	this.controller.listen("unitField", Mojo.Event.propertyChanged, this.unitChanged.bindAsEventListener(this));

	
	this.controller.setupWidget("ageField", {
		charsAllow: isValidFPNumber,
		modifierState: Mojo.Widget.numLock
	}, {value: age});
	
		this.controller.setupWidget("weightField", {
		charsAllow: isValidFPNumber,
		modifierState: Mojo.Widget.numLock
	}, {value: weight});
	
	this.controller.setupWidget("heightField", {
		charsAllow: isValidFPNumber,
		modifierState: Mojo.Widget.numLock
	}, {value: height});
	

},

unitChanged: function() {
//change unit display in bmi scene
var unitchoice = this.togglemodel.togglestate;

if (!unitchoice){
$("weightUnit").update("<span class=\"si\">(lbs)</span>");
$("heightUnit").update("<span class=\"si\">(ins)</span>");
}

if (unitchoice){
$("weightUnit").update("<span class=\"si\">(kg)</span>");
$("heightUnit").update("<span class=\"si\">(cm)</span>");
}
},


	calculate: function() {
	var result = harriscalc(this.togglemodel.togglestate, this.sexModel.value, this.activityModel.value, parseFloat($("ageField").mojo.getValue()),parseFloat($("weightField").mojo.getValue()), parseFloat($("heightField").mojo.getValue()));
weight=result.weight;
height=result.height;
age= result.age;


if (isNaN(result.harris)){
return errormsg;
}
else {
	return "The Basal Metabolic Rate is " + result.bmr + " kcal/day." + "<br />The Daily Calorie requirement is " + result.harris +" kcal/day in order to maintain current weight at chosen level of activity";
	}
	}
});





